/*
 * automat.h
 *
 *  Created on: 2011-3-6
 *      Author: hao
 */

#ifndef AUTOMAT_H_
#define AUTOMAT_H_

#include <vector>
#include <functional>
#include "HashTable.hpp"

using namespace std;

class Automat{

	vector< HashTable< int > > TransTable;

	vector< int > accState;

	HashTable< function< void( char * data, int length, int pos ) > > ActionTable;

public:

	Automat( int nState );

	~Automat();

	void InsertAccState( int state );

	void InsertState( int state, char cLookahead, int target_state, int ReturnValue = 0 );

	void InsertAction( int state, function< void( char * data, int length, int pos ) > fun );

	int Run( char * pData, int len, int & start_pos );


};


#endif /* AUTOMAT_H_ */
